package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TOperation;
import com.ruoyi.system.service.ITOperationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 操作记录Controller
 * 
 * @author ruoyi
 * @date 2022-03-17
 */
@RestController
@RequestMapping("/system/operation")
public class TOperationController extends BaseController
{
    @Autowired
    private ITOperationService tOperationService;

    /**
     * 查询操作记录列表
     */

    @GetMapping("/list")
    public TableDataInfo list(TOperation tOperation)
    {
        startPage();
        List<TOperation> list = tOperationService.selectTOperationList(tOperation);
        return getDataTable(list);
    }

    /**
     * 导出操作记录列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, TOperation tOperation)
    {
        List<TOperation> list = tOperationService.selectTOperationList(tOperation);
        ExcelUtil<TOperation> util = new ExcelUtil<TOperation>(TOperation.class);
        util.exportExcel(response, list, "操作记录数据");
    }

    /**
     * 获取操作记录详细信息
     */
    @GetMapping(value = "/{oid}")
    public AjaxResult getInfo(@PathVariable("oid") Long oid)
    {
        return AjaxResult.success(tOperationService.selectTOperationByOid(oid));
    }

    /**
     * 新增操作记录
     */
    @PostMapping
    public AjaxResult add(@RequestBody TOperation tOperation)
    {
        return toAjax(tOperationService.insertTOperation(tOperation));
    }

    /**
     * 修改操作记录
     */

    @PutMapping
    public AjaxResult edit(@RequestBody TOperation tOperation)
    {
        return toAjax(tOperationService.updateTOperation(tOperation));
    }

    /**
     * 删除操作记录
     */
	@DeleteMapping("/{oids}")
    public AjaxResult remove(@PathVariable Long[] oids)
    {
        return toAjax(tOperationService.deleteTOperationByOids(oids));
    }
}
